package me.zixing.java.guiandthread.domain;

import lombok.AllArgsConstructor;
import lombok.ToString;

import java.util.concurrent.TimeUnit;

/**
 * Created by bingh on 2017/11/13.
 */

public class Tortoise extends SportableContent {
    public Tortoise(String name,double x,double y,int length,int status){
        super(name,x,y,length,status);
    }
    @Override
    public void run() {
        super.run();
        //默认运动 x++
        try{
            while(x < 100){
                x++;
                fireListener(new SportableContentEvent(this,1));
                System.out.println(getName()+":"+x);
                TimeUnit.MILLISECONDS.sleep(100);
            }
            fireListener(new SportableContentEvent(this,2));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
